<template>
  <div class="app-container">
    <el-row>
      <!-- 顶部搜索栏 -->
      <el-form ref="queryForm" :model="queryParams" v-show="showSearch" :inline="true">
        <el-form-item label="产线" prop="areaID">
          <el-input
            v-model="queryParams.areaID"
            placeholder="请输入产线"
            clearable
            size="small"
            style="width: 240px"
          />
        </el-form-item>
        <el-form-item label="产品名称" prop="productName">
          <el-input
            v-model="queryParams.productName"
            placeholder="请输入产品名称"
            clearable
            size="small"
            style="width: 240px"
          />
        </el-form-item>
        <el-form-item label="炉位" prop="furnace">
          <el-input
            v-model="queryParams.furnace"
            placeholder="请输入炉位"
            clearable
            size="small"
            style="width: 240px"
          />
        </el-form-item>
        <el-form-item label="打印人" prop="uploadUser">
          <el-input
            v-model="queryParams.uploadUser"
            placeholder="请输入打印人"
            clearable
            size="small"
            style="width: 240px"
          />
        </el-form-item>
        <el-form-item label="班组" prop="team">
          <el-select v-model="queryParams.team" placeholder="请选择班组" clearable :style="{width: '100%'}">
            <el-option v-for="(item, index) in teamOptions" :key="index" :label="item.label" :value="item.value"
                       :disabled="item.disabled"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="标签打印日期">
          <el-date-picker
            v-model="dateRange"
            size="small"
            style="width: 240px"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <!-- 后台回显表格 -->
      <el-table v-loading="loading" :data="putList">
        <el-table-column label="序号" align="center" key="put_id" prop="put_id" v-if="columns[0].visible"  />
        <el-table-column label="班组" align="center" key="team" prop="team" v-if="columns[1].visible"  />
        <el-table-column label="炉位" align="center" key="furnace" prop="furnace" v-if="columns[2].visible"  />
        <el-table-column label="产品名称" align="center" key="productName" prop="productName" v-if="columns[3].visible" width="160" :show-overflow-tooltip="true" />
        <el-table-column label="产线" align="center" key="areaID" prop="areaID" v-if="columns[4].visible" :show-overflow-tooltip="true" />
        <el-table-column label="图案" align="center" prop="patterns" v-if="columns[5].visible" width="160">
          <template slot-scope="scope">
            <img v-if="scope.row.patterns != ''" v-bind:src="imgurl + scope.row.patterns[0].patternImgUrl" style="max-width: 100%;height: 30px;">
          </template>
        </el-table-column>
        <el-table-column label="打印张数" align="center" key="printcount" prop="printcount" v-if="columns[6].visible" :show-overflow-tooltip="true">
<!--          <template slot-scope="scope">-->
<!--            <el-input v-model="scope.row.printcount"></el-input>-->
<!--          </template>-->
        </el-table-column>
        <el-table-column label="打印人" align="center" prop="uploadUser" v-if="columns[7].visible" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            {{ scope.row.users[0].nickName }}
          </template>
        </el-table-column>
        <el-table-column label="打印日期" align="center" prop="uploadDate" v-if="columns[8].visible" width="160">
          <template slot-scope="scope">
            <span>{{ scope.row.uploadDate }}</span>
          </template>
        </el-table-column>
      </el-table>

      <!-- 底部pagination -->
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-row>
  </div>
</template>

<script>
import { getPutList } from '@/api/wire/chart/chart'

export default {
  name: 'Chart',
  data() {
    return {
      //图片地址前缀
      imgurl: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      putIds: [],
      productNames:[],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      //产品已打印的数据
      putList: null,
      // 弹出层标题
      title: "",
      // 图案选项
      patternOptions: undefined,
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        team:undefined,
        furnace:undefined,
        productName:undefined,
        areaID:undefined,
        uploadUser:undefined,
      },
      // 日期范围
      dateRange: [],
      // 列信息
      columns: [
        { key: 0, label: `序号`, visible: true },
        { key: 1, label: `班组`, visible: true },
        { key: 2, label: `炉位`, visible: true },
        { key: 3, label: `产品名称`, visible: true },
        { key: 4, label: `产线`, visible: true },
        { key: 5, label: `图案`, visible: true , name: 'patternImgUrl' },
        { key: 6, label: `打印张数`, visible: true },
        { key: 7, label: `打印人`, visible: true },
        { key: 8, label: `打印日期`, visible: true },
      ],
      teamOptions: [{
        "label": "A",
        "value": "A"
      }, {
        "label": "B",
        "value": "B"
      }, {
        "label": "C",
        "value": "C"
      }, {
        "label": "D",
        "value": "D"
      }],
    }
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询产品列表 */
    getList() {
      this.loading = true;
      getPutList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.putList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
}
</script>

<style scoped>

</style>
